package com.punch.common.feign.fallback;

import com.punch.common.feign.FeignHolidayService;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

@Slf4j
@Component
public class FeignHolidayServiceFallbackFactory implements FallbackFactory<FeignHolidayService> {
    @Override
    public FeignHolidayService create(Throwable throwable) {
        return new FeignHolidayService() {
            @Override
            public List<LocalDate> listHoliday(LocalDate startDay, LocalDate endDay) {
                log.error("查找节假日移除:{}-{}", startDay, endDay, throwable);
                return new ArrayList<>();
            }
        };
    }
}
